<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const shopCartList = [{
                cartInfoList: [{
                        skuNum: 1,
                        skuPrice: 1299,
                    },
                    {
                        skuNum: 3,
                        skuPrice: 777,
                    },
                    {
                        skuNum: 2,
                        skuPrice: 900,
                    },
                ],
            },

            {
                cartInfoList: [{
                        skuNum: 2,
                        skuPrice: 420,
                    },
                    {
                        skuNum: 4,
                        skuPrice: 99,
                    },
                ],
            },
        ];

        /* 
        双层数据的处理 把每层数据单独看成一个数据,一个个的处理
        */
        const re = shopCartList.reduce((p1, i1) => {
            const i1re = i1.cartInfoList.reduce((p2, i2) => {
                return p2 + i2.skuNum
            },0)
            return p1 + i1re
        },0)
        console.log(re);
    </script>
</body>

</html>